home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11473 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: const pointer confusion...
  5. Date: 24 Mar 1996 11:40:23 -0600
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4j41e7$nep@solutions.solon.com>
  10. References: <4j06gm$7oa@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13.  
  14. "Reed R. Mangino" <mangino@planet.net> writes:
  15.  
  16. >Could someone please straighten me out on this:
  17.  
  18. >1) const int *p = 10;
  19. >    p is a constant pointer to an int, right? While p can be made to
  20. >    point to something else, *p can never be assigned to, right?
  21.  
  22. "p" is a pointer to a "const int", and the pointer is in no way constant,
  23. as you paraphrase correctly.
  24.  
  25. >2) int *const p;
  26. >    p is a pointer to an integer.  *p can be assigned to, but p can
  27. >    never be made to point to another address in memory, right?
  28.  
  29. So, in this case, "p" is a constant pointer to an int, isn't it?
  30.  
  31. >3) int const *p;
  32. >    What the heck is this?  I can't find anything like this in my 
  33. >    books, but my compiler thinks everything is hunky doory!???
  34.  
  35. "p" is a pointer to an "int const", which happens to be the same as 
  36. a pointer to an "const int".
  37.  
  38. Kurt
  39. --
  40. | Kurt Watzka                             Phone : +49-89-2180-6254
  41. | watzka@stat.uni-muenchen.de
  42. | ua302aa@sunmail.lrz-muenchen.de
  43.